{% extends 'classroom-manage/layout.html.twig' %}

{% block title %}{{ 'classroom.basic_info'|trans }} - {{ parent() }}{% endblock %}

{% set script_arguments = {
tagMatchUrl: path('tag_match'),
classroomStatus: classroom.status
} %}

{% set side_nav = 'base' %}

{% do script(['libs/jquery-validation.js', 'libs/es-ckeditor/ckeditor.js', 'libs/bootstrap-datetimepicker.js', 'libs/select2.js', 'app/js/classroom-manage/set-info/index.js']) %}

{% block main %}
  <div class="panel panel-default" role="classroom-manage-base">
    <div class="panel-heading">{{ 'classroom.basic_info'|trans }}</div>
    <div class="panel-body">
      {{ web_macro.flash_messages() }}
      <form class="form-horizontal" method="post" id="classroom-set-form" novalidate>
        <div class="row form-group">
          <div class="col-sm-2 control-label">
            <label class="control-label-required" for="title" >{{ 'classroom.name_label'|trans }}</label>
          </div>
          <div class="controls col-sm-8">
            <input name="title" type="text" id="title" class="form-control" value="{{ classroom.title }}"/>
          </div>
        </div>
        <div class="row form-group">
          <div class="col-sm-2 control-label">
            <label>{{ 'classroom.about'|trans }}</label>
          </div>
          <div class="controls col-sm-8">
            <textarea name="about" class="form-control" rows="6"
            data-image-upload-url="{{ path('editor_upload', {token:upload_token('default')}) }}"
            data-flash-upload-url="{{ path('editor_upload', {token:upload_token('default', 'flash')}) }}"
            id="about">{{ classroom.about|raw }}</textarea>
            <div class="help-block">{{ 'classroom.about_tips'|trans }}</div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">{{ 'classroom.tag_label'|trans }}</label>
          <div class="col-sm-8 controls">
            <input type="text" id="classroom_tags" name="tags"  class="width-full select2-offscreen"
              tabindex="-1" value="{{ tags|join(',') }}"
              data-explain="{{ 'classroom.tag_tips'|trans }}">
            <div class="help-block">{{ 'classroom.tag_tips'|trans }}</div>
          </div>
        </div>
        <div class="row form-group">
          <div class="col-sm-2 control-label">
            <label>{{ 'classroom.show_label'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}</label>
          </div>
          <div class="col-sm-8 controls radios">
            <label>
              <input id="showable-open" type="radio" name="showable" value="1" data-showable="{{ classroom.showable }}"> {{ 'classroom.open_radio'|trans }}
            </label>
            <label>
              <input id="showable-close" type="radio" name="showable" value="0"> {{ 'classroom.close_radio'|trans }}
            </label>
            <div class="help-block">{{ 'classroom.show_tips'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}</div>
          </div>

        </div>
        <div class="row form-group" id='buyable'>
          <div class="col-sm-2 control-label">
            <label>{{ setting("classroom.name")|default("classroom"|trans) }}{{ 'classroom.buy_label'|trans }}</label>
          </div>
          <div class="col-sm-8 controls radios">
            <label>
              <input id="buyable-open" type="radio" name="buyable" value="1" data-buyable="{{ classroom.buyable }}"> {{ 'classroom.open_radio'|trans }}
            </label>
            <label>
              <input id="buyable-close" type="radio" name="buyable" value="0"> {{ 'classroom.close_radio'|trans }}
            </label>
            <div class="help-block">{{ 'classroom.buy_tips'|trans({'%name%':setting('classroom.name')|default('classroom'|trans)}) }}</div>
          </div>
        </div>
        <div class="form-group cd-mb16">
          <label class="col-sm-2 control-label">{{'classroom.expiry_mode_label'|trans}}</label>
          <div class="col-sm-8 controls radios">
            {% if classroom.status == 'draft' %}
              <input type="hidden" name="expiryMode" value="{{ classroom.expiryMode }}">
              {{ radios('expiryMode', {'date':'classroom.expiry_mode_end_date'|trans, 'days':'classroom.expiry_mode_days'|trans,'forever':'classroom.expiry_mode_forever'|trans}, classroom.expiryMode|default('forever')) }}
            {% else %}
              {{ radios('expiryMode', {'date':'classroom.expiry_mode_end_date'|trans, 'days':'classroom.expiry_mode_days'|trans,'forever':'classroom.expiry_mode_forever'|trans}, classroom.expiryMode|default('forever'), 'disabled') }}
              <input type="hidden" name="expiryMode" value="{{ classroom.expiryMode|default('forever') }}">
            {% endif %}
            <a href="{{ path('classroom_expiry_date_rule') }}" target="_blank">{{'classroom.watch_expiry_mode_rile'|trans}}</a>
            <div class="color-warning">{{ 'classroom.expiry_mode.first_publish_tips'|trans }}</div>
          </div>
        </div>
        <div class="form-group expiry-value-js {% if classroom.expiryMode|default('forever') == 'forever' %} hidden {% endif %}">
          <div class="col-sm-offset-2 col-sm-10 controls">
            <input type="text" id="classroom_expiryValue" name="expiryValue"
              value="{% if classroom.expiryMode|default('forever') == 'date' %}{{ classroom.expiryValue|date('Y-m-d') }}{% else %}{{ classroom.expiryValue }}{% endif %}"
              class="form-control width-input width-input-large">
              <span {% if classroom.expiryMode|default('forever') != 'days' %}class="hidden" {% endif %}>
                {{ 'site.date.day'|trans }}
              </span>
            {% set date_help = 'classroom.expiry_mode_end_date_tips'|trans %}
            {% set days_help = 'classroom.expiry_mode_days_tips'|trans %}

            <div class="help-block" data-date="{{ date_help }}" data-days="{{ days_help }}">
              {% if classroom.expiryMode|default('forever') == 'date' %}  {{ date_help }}{% elseif  classroom.expiryMode|default('forever') == 'days' %}{{ days_help }} {% endif %}
            </div>
          </div>
        </div>
        <div class="form-group">
          <label class="col-sm-2 control-label">{{ 'classroom.category'|trans }}</label>
          <div class="col-sm-8 controls">
            <select id="course_categoryId" name="categoryId" required="required" class="form-control width-input width-input-large">
              {{ select_options(category_choices('classroom'), classroom.categoryId, {0:'classroom.category'|trans}) }}

            </select>
            <div class="help-block" style="display:none;"></div>
          </div>
        </div>
        {% include 'org/org-tree-select-webpack.html.twig' with {orgCode: classroom.orgCode, inputClass: 'width-input width-input-large'} %}
        <div class="row form-group">
          <div class="col-sm-2 control-label"></div>
          <div class="controls col-sm-8">
            <button class="btn btn-primary" id="classroom-save">{{ 'form.btn.submit'|trans }}</button>
          </div>
        </div>

        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
      </form>
    </div>
  </div>
{% endblock %}
